import type { AIProvider } from './base';
import { OpenAIProvider } from './openai';
import { GitHubCopilotProvider } from './github-copilot';
import { DeepSeekProvider } from './deepseek';
import { ClaudeProvider } from './claude';
import { GeminiProvider } from './gemini';

export * from './base';
export * from './openai';
export * from './github-copilot';
export * from './deepseek';
export * from './claude';
export * from './gemini';

/**
 * AI服务提供商工厂类
 * 用于管理和获取所有可用的AI服务提供商
 */
export class AIProviderFactory {
  private static instance: AIProviderFactory;
  private providers: Map<string, AIProvider> = new Map();

  private constructor() {
    // 注册默认提供商
    this.registerProvider(new OpenAIProvider());
    this.registerProvider(new GitHubCopilotProvider());
    this.registerProvider(new DeepSeekProvider());
    this.registerProvider(new ClaudeProvider());
    this.registerProvider(new GeminiProvider());
  }

  /**
   * 获取工厂类实例（单例模式）
   */
  public static getInstance(): AIProviderFactory {
    if (!AIProviderFactory.instance) {
      AIProviderFactory.instance = new AIProviderFactory();
    }
    return AIProviderFactory.instance;
  }

  /**
   * 注册新的服务提供商
   * @param provider 提供商实例
   */
  public registerProvider(provider: AIProvider): void {
    this.providers.set(provider.id, provider);
  }

  /**
   * 获取特定ID的服务提供商
   * @param id 提供商ID
   * @returns 提供商实例，如果不存在则返回undefined
   */
  public getProvider(id: string): AIProvider | undefined {
    return this.providers.get(id);
  }

  /**
   * 获取所有注册的服务提供商
   * @returns 所有提供商实例的数组
   */
  public getAllProviders(): AIProvider[] {
    return Array.from(this.providers.values());
  }
} 